from django.conf.urls.defaults import *
from django.conf import settings
from django.views.generic import list_detail

import browsertests.tests.views
import browsertests.tests as tests
from browsertests.tests.models import Test

PAGINATE_BY = 100

test_list = {
    'queryset': Test.objects.filter(deleted=False).select_related(),
    'template_object_name': 'test',
    'paginate_by': PAGINATE_BY,
}

test_list_raw = {
    'queryset': Test.objects.filter(deleted=False).select_related(),
    'template_object_name': 'test',
    'template_name': 'tests/test_list_raw.html',
}

test_detail = {
    'queryset': Test.objects.select_related(),
    'template_object_name': 'test',
    'extra_context': {'TESTS_URL': settings.TESTS_URL},
}

urlpatterns = patterns('',
    url(
        regex   = '^page(?P<page>\d+)/$',
        view    = list_detail.object_list,
        kwargs  = test_list,
        name    = 'test-list',
    ),
    url(
        regex   = '^raw/$',
        view    = list_detail.object_list,
        kwargs  = test_list_raw,
        name    = 'test-list-raw',
    ),
    url(
        regex   = '^search/$',
        view    = tests.views.test_search,
        name    = 'test-search',
    ),
    url(
        regex   = '^(?P<object_id>.+)/$',
        view    = list_detail.object_detail,
        kwargs  = test_detail,
        name    = 'test-detail',
    ),
)
